
var da=dataset.make()

var list

/////////////////
/* 启动页面事件 */
/////////////////
window.addEventListener('resize', function () {


})

cale2s=`
<button class="calc btn btn-secondary rounded-pill px-3 m-3" name="calc24">四环电阻</a>
<button class="calc btn btn-secondary rounded-pill px-3 m-3" name="calc25">五环电阻</a>
<button class="calc btn btn-secondary rounded-pill px-3 m-3" name="calc2tp">贴片电阻</a>
<button class="calc btn btn-secondary rounded-pill px-3 m-3" name="calc2xl">Led限流电阻</a>
<button class="calc btn btn-secondary rounded-pill px-3 m-3" name="calc2bl">电阻并联后阻值</a>
<button class="calc btn btn-secondary rounded-pill px-3 m-3" name="info">信息</a>
` 
function calcfunc(){
  // console.log(this)
  var idfra = document.getElementById('fra')
  var idfra2 = document.getElementById('fra2')

  var listcalc = document.getElementsByClassName("calc")
  for (var i = 0; i < listcalc.length; i++) {
    var elem = listcalc[i];
    elem.className="calc btn btn-secondary rounded-pill px-3 m-3"
  }
  this.className="calc btn btn-primary rounded-pill px-3 m-3 active"
  idfra2.src="page/calc/"+this.name+".html"
  idfra2.hidden=false
  idfra.hidden=true
}


intervalId = null;

//////////////
/* 加载事件 */
/////////////
window.addEventListener("load", function () {
  var windowHeight = window.innerHeight;
  var newpich = Math.round(windowHeight * 1200 / 1440)
  var headh = Math.round(windowHeight * 90 / 1440)

  var idpic = document.getElementById('picture');
  idpic.style.setProperty('height', newpich + 'px');

  var ele2 = document.getElementById('cont')
  ele2.style.setProperty('min-height', headh + 'vh')

  var windowHeight = window.innerHeight;
  var newpich = Math.round(windowHeight * 1200 / 1440)
  var idfra = document.getElementById('fra')
  idfra.height = newpich

  ///////左边选单里面的动效///////
  var elexd = document.getElementsByClassName("nav-link link-body-emphasis")
  for (var i = 0; i < elexd.length; i++) {
    var elem = elexd[i];

    // 鼠标进入事件
    elem.addEventListener('mouseover', function (event) {
      this.className = "nav-link active"
    });

    // 鼠标离开事件
    elem.addEventListener('mouseout', function (event) {
      this.className = "nav-link link-body-emphasis"
    });
  }
  /////////////////////////////////////////

  var slideIndex = 0;

  var divToRemove = document.getElementById('picture');

  ////////定时模块///////定时执行修改图片
  intervalId = setInterval(function () {

    if (slideIndex == da.pictureCount) slideIndex = 0
    slideIndex++


    //// 创建并添加新的图片元素
    divToRemove.src = da.picturePath+da.pictureName+'(' + slideIndex + ').'+da.pictureExName
    //alert(divToRemove.src)
  }, 15000);
  ///////////////////////////////////////////////////

  var idty=document.getElementById("ty")
  var idsele=document.getElementById("selector")
  var idcentercont=document.getElementById("centercont")
  var idnews=document.getElementById("news")
  var fraselector=document.getElementById("fraselector")

  idty.addEventListener("click",()=>{
    idcentercont.style.setProperty("grid-template-columns","180px 1fr 32%")
    idsele.className="mt-2 rounded-3"
    idsele.style.setProperty("height","200px")
    idsele.style.setProperty("width","auto")
    idsele.style.setProperty("padding","4 0 0 0")
    idsele.innerHTML=cale2s

    listcalc=document.getElementsByClassName("calc")
    var idfra2=document.getElementById("fra2")
    for (var i = 0; i < listcalc.length; i++) {
      ////加上绑定后就可以指定控件对象，否则this为整个窗口对象
      listcalc[i].addEventListener("click",calcfunc.bind(listcalc[i]))
      
    }

    idpic.style.setProperty("height",(newpich-206)+"px")
    idfra.hidden=true
  })

  idnews.addEventListener("click",()=>{
    idcentercont.style.setProperty("grid-template-columns","180px 1fr 16%")
    idsele.className=""
    idsele.innerHTML=""
    idsele.style.setProperty("height","0px")
    idsele.style.setProperty("width","0px")
    idpic.style.setProperty("height",newpich+"px")
    idfra.hidden=false
  })

})



/////////////////
/* 页面关闭事件 */
/////////////////
window.addEventListener('beforeunload', function () {
  ////删除定时器
  clearInterval(intervalId);
});

////未来添加适配16:10分辨率的机器，带鱼屏不考虑了，我买不起🤣

